package cn.wh.ymcc.web.controller;


import cn.wh.ymcc.dto.RegisterDto;
import cn.wh.ymcc.result.JSONResult;
import cn.wh.ymcc.service.IVerifyCodeSerivce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {
    @Autowired
    private IVerifyCodeSerivce VerifyCodeSerivce;


    @GetMapping("/imageCode/{imageCodeKey}")
    public JSONResult createImageCode(@PathVariable("imageCodeKey") String imageCodeKey){
        //返回图片Base64编码的字符串
        String imageCode = VerifyCodeSerivce.imageCode(imageCodeKey);
        return JSONResult.success(imageCode);
    }

    //短信验证码
    @PostMapping("/sendSmsCode")
    public JSONResult SmsCode(@RequestBody RegisterDto dto){
        VerifyCodeSerivce.smsCode(dto);
        return JSONResult.success();
    }
}
